﻿<UserControl x:Class="DevFX.Modules.Passport.UserModule.View.UserView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
             xmlns:dataFormToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             mc:Ignorable="d" 
             xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
             xmlns:uc="clr-namespace:DevFX.Infrastructure.ViewUtility.UC;assembly=DevFX.Infrastructure"
             xmlns:vc="clr-namespace:DevFX.Infrastructure.ViewUtility.ValueConverters;assembly=DevFX.Infrastructure"
             Width="924" Height="568">

    <UserControl.Resources>

        <SolidColorBrush x:Key="BaseColorBrush" Color="#FF133247"/>
        <SolidColorBrush x:Key="ForegroundColorBrush" Color="#FFFFFFFF"/>
        <Style x:Key="ButtonStyle" TargetType="ButtonBase">
            <Setter Property="Background" Value="{StaticResource BaseColorBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource ForegroundColorBrush}" />
            <Setter Property="Padding" Value="4" />
            <Setter Property="FontFamily" Value="Trebuchet MS"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualStateGroup.Transitions>
                                        <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                        <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                    </vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BorderTransparency" Storyboard.TargetProperty="(Shape.StrokeThickness)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="7"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BorderTransparency" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.35"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#CCFFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BorderTransparency" Storyboard.TargetProperty="(Shape.StrokeThickness)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="7"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ScalableBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ScalableBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#CCFFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.75"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused"/>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>

                            <!-- Start:UI -->
                            <Grid x:Name="ScalableBorder" RenderTransformOrigin="0.5,0.5">
                                <Grid.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </Grid.RenderTransform>
                                <Path Stretch="Fill" Stroke="{TemplateBinding Background}" Data="M20.231335,0.5 L26.636795,0.5 L153.5,0.5 L162.5,0.5 C163.05229,0.4999994 163.5,0.94771463 163.5,1.5000005 L163.5,10.499999 L163.5,35.943314 L163.5,41.943314 C163.5,53.542103 155.39055,59.5 143.3632,59.5 L140.3632,59.5 L10.499999,59.5 L1.5000005,59.5 C0.94771522,59.5 0.5,59.052284 0.5,58.5 L0.5,49.5 L0.5,23.056734 L0.5,18.056734 C0.5,7.0391827 9.4203978,0.4999994 20.636806,0.5" StrokeThickness="3" x:Name="BackColor" Fill="{TemplateBinding Background}"/>
                                <Path Stretch="Fill" Stroke="#FF888888" Data="M20.231335,0.5 L26.636795,0.5 L153.5,0.5 L162.5,0.5 C163.05229,0.4999994 163.5,0.94771463 163.5,1.5000005 L163.5,10.499999 L163.5,35.943314 L163.5,41.943314 C163.5,53.542103 155.39055,59.5 143.3632,59.5 L140.3632,59.5 L10.499999,59.5 L1.5000005,59.5 C0.94771522,59.5 0.5,59.052284 0.5,58.5 L0.5,49.5 L0.5,23.056734 L0.5,18.056734 C0.5,7.0391827 9.4203978,0.4999994 20.636806,0.5" StrokeThickness="3" x:Name="Background">
                                    <Path.Fill>
                                        <LinearGradientBrush StartPoint="0.7,0" EndPoint="0.7,1">
                                            <GradientStop Color="#CCFFFFFF" Offset="0" />
                                            <GradientStop Color="#AAFFFFFF" Offset="0.285" />
                                            <GradientStop Color="#88FFFFFF" Offset="0.285" />
                                            <GradientStop Color="#19FFFFFF" Offset="1" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Path x:Name="BorderTransparency" Stretch="Fill" StrokeThickness="7" Stroke="#FFFFFFFF" Opacity="0.25" Margin=".5" Data="M10.499999,0.5 L16.5,0.5 153.5,0.5 162.5,0.5 C163.05229,0.4999994 163.5,0.94771463 163.5,1.5000005 L163.5,10.499999 163.5,43.499999 163.5,49.499999 C163.5,55.022846 159.02284,59.499999 153.5,59.499999 L150.5,59.499999 10.499999,59.499999 1.5000005,59.499999 C0.94771522,59.499999 0.5,59.052284 0.5,58.499999 L0.5,49.499999 0.5,15.499999 0.5,10.499999 C0.5,4.9771518 4.9771523,0.4999994 10.499999,0.5 z"/>
                                <ContentPresenter 
                                    x:Name="contentPresenter" 
                                    Content="{TemplateBinding Content}" 
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    Margin="{TemplateBinding Padding}" 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <Path x:Name="FocusVisual" Stretch="Fill" StrokeThickness="1" Stroke="#BFFFFFFF" StrokeDashCap="Square" StrokeDashArray="1 2" Margin="5" Visibility="Collapsed" Data="M10.499999,0.5 L16.5,0.5 153.5,0.5 162.5,0.5 C163.05229,0.4999994 163.5,0.94771463 163.5,1.5000005 L163.5,10.499999 163.5,43.499999 163.5,49.499999 C163.5,55.022846 159.02284,59.499999 153.5,59.499999 L150.5,59.499999 10.499999,59.499999 1.5000005,59.499999 C0.94771522,59.499999 0.5,59.052284 0.5,58.499999 L0.5,49.499999 0.5,15.499999 0.5,10.499999 C0.5,4.9771518 4.9771523,0.4999994 10.499999,0.5 z"/>
                                <Path x:Name="DisabledVisual" Stretch="Fill" Fill="#FFFFFFFF" StrokeThickness="3" Stroke="#FFFFFFFF" Visibility="Collapsed" Data="M10.499999,0.5 L16.5,0.5 153.5,0.5 162.5,0.5 C163.05229,0.4999994 163.5,0.94771463 163.5,1.5000005 L163.5,10.499999 163.5,43.499999 163.5,49.499999 C163.5,55.022846 159.02284,59.499999 153.5,59.499999 L150.5,59.499999 10.499999,59.499999 1.5000005,59.499999 C0.94771522,59.499999 0.5,59.052284 0.5,58.499999 L0.5,49.499999 0.5,15.499999 0.5,10.499999 C0.5,4.9771518 4.9771523,0.4999994 10.499999,0.5 z" Opacity="0.75"/>
                            </Grid>
                            <!-- End:UI -->
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Height" Value="30"/>
            <Setter Property="Width" Value="100"/>
        </Style>
        <SolidColorBrush x:Key="BaseFontBrush" Color="#FF429DDB"/>
        <SolidColorBrush x:Key="LightBackgroundBrush" Color="#FF9BCCEE"/>
        <SolidColorBrush x:Key="DataGridRowBackgroundBrush" Color="#FFE4F1FA"/>

        <!-- Value Converters -->
        <vc:ShowIfTrueConverter x:Key="ShowIfTrueConverter" />

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource BaseColorBrush}">
        <Border Padding="4" BorderThickness="2" BorderBrush="{StaticResource BaseColorBrush}" Margin="12">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="59"/>
                    <RowDefinition Height="0.225*"/>
                    <RowDefinition Height="0.775*"/>
                </Grid.RowDefinitions>
                <Border Margin="4" Grid.Row="1" BorderThickness="1" CornerRadius="5" BorderBrush="{StaticResource BaseFontBrush}" Padding="3" Background="White">
                    <data:DataGrid x:Name="dataGrid" ItemsSource="{Binding Path=Users, Mode=OneWay}" IsReadOnly="True" AutoGenerateColumns="False" 
                                   BorderThickness="0" Background="{StaticResource DataGridRowBackgroundBrush}" FontFamily="Trebuchet MS" 
                                   FontSize="13.333" Margin="0,-1,0,1">
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Binding="{Binding UserName, Mode=OneWay}"/>
                            <data:DataGridTextColumn Binding="{Binding Nickname, Mode=OneWay}"/>
                            <data:DataGridTextColumn Binding="{Binding Email, Mode=OneWay}"/>
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Border>

                <!-- "Busy" Overlay -->
                <Border x:Name="WaitBorder" 
                        Grid.Row="1" 
                        Visibility="{Binding IsBusy, Converter={StaticResource ShowIfTrueConverter}}" 
                        HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch" >
                    <Border.Background>
                        <SolidColorBrush Color="Black" Opacity="0.3" />
                    </Border.Background>

                    <uc:WaitCursorAnimation x:Name="waitCursorAnimation"
                                            IsAnimating="{Binding Path=IsBusy}"
                                            HorizontalAlignment="Center"    
                                            VerticalAlignment="Center"/>
                </Border>

                <Border  Margin="4" Grid.Row="2" BorderThickness="1" CornerRadius="5" BorderBrush="{StaticResource BaseFontBrush}" Padding="3" 
                         Background="{StaticResource LightBackgroundBrush}">
                    <!-- 
						CommandButtonsVisibility="All" 
						CommandButtonsVisibility="Edit, Add, Delete, Commit, Cancel" 
					-->
                    <dataFormToolkit:DataForm x:Name="dataForm" ItemsSource="{Binding Path=Users, Mode=OneWay}" BorderThickness="0" FontFamily="Trebuchet MS" 
                                              FontSize="13.333" CommitButtonContent="Save" CancelButtonContent="Cancel" Header="User Details" 
						                      AutoEdit="False" AutoCommit="False" AutoGenerateFields="True" 
                                              CommandButtonsVisibility="Edit, Add, Delete, Commit, Cancel" 
                                              CommitButtonStyle="{StaticResource ButtonStyle}" CancelButtonStyle="{StaticResource ButtonStyle}" 
                                              DescriptionViewerPosition="BesideLabel" LabelPosition="Left">
                        <dataFormToolkit:DataForm.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FFE8F3FC" Offset="0"/>
                                <GradientStop Color="#FF9BCCEE" Offset="0.108"/>
                            </LinearGradientBrush>
                        </dataFormToolkit:DataForm.Background>
                        <dataFormToolkit:DataForm.EditTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <dataFormToolkit:DataField>
                                        <TextBlock Text="{Binding UserName, Mode=TwoWay}" />
                                    </dataFormToolkit:DataField>
                                    <dataFormToolkit:DataField>
                                        <TextBox Text="{Binding Nickname, Mode=TwoWay}" />
                                    </dataFormToolkit:DataField>
                                    <dataFormToolkit:DataField>
                                        <TextBox Text="{Binding Email, Mode=TwoWay}" />
                                    </dataFormToolkit:DataField>
                                    <dataFormToolkit:DataField>
                                        <TextBox Text="{Binding Question, Mode=TwoWay}" />
                                    </dataFormToolkit:DataField>
                                    <dataFormToolkit:DataField>
                                        <TextBox Text="{Binding Answer, Mode=TwoWay}" />
                                    </dataFormToolkit:DataField>
                                </StackPanel>
                            </DataTemplate>
                        </dataFormToolkit:DataForm.EditTemplate>
                    </dataFormToolkit:DataForm>
                </Border>
                <TextBlock Text="User View" TextWrapping="NoWrap" FontFamily="Georgia" FontSize="48" Foreground="{StaticResource BaseFontBrush}" 
                           HorizontalAlignment="Center" Margin="0" Grid.ColumnSpan="2" d:LayoutOverrides="GridBox">
					<TextBlock.Effect>
						<DropShadowEffect Color="#FF746969" ShadowDepth="3"/>
					</TextBlock.Effect>
                </TextBlock>
            </Grid>
        </Border>
    </Grid>
</UserControl>
